package com.briup.estore.common.dao;

import com.briup.estore.common.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author adam
 * @date 2022/1/12
 */
@Repository
public interface IUserDao extends JpaRepository<User, Long> {
    User findByLoginName(String loginName);

    Page<User> findByLoginNameContains(String loginName, Pageable pageable);

    @Modifying
    @Query("update  User set isLock =true where id= ?1")
    void disable(long id);

    @Modifying
    @Query("update  User set isLock =false where id= ?1")
    void enable(long id);
}
